﻿/***
*
*只用于解析OBJ的解析函数objmodel.js
*
*Daniel
*2017.12.18
*/
define(["mtl", "obj"], function (){
    var objLoder = function(){
        this.obj =  objloader;
        this.mtl = mtlloader;
        this.parse = parse;
        this.jsonParse = JSONparse;
    };
    //解析OBJ
    function objloader(text, materials){
        var load = new THREE.OBJLoader();
        if (materials !== undefined) load.setMaterials(materials);
        var mesh = load.parse(text);
        return mesh;
    }
    function mtlloader(text, path){
        var mtlo = new THREE.MTLLoader();
        mtlo.setPath(path);
        var material = mtlo.parse(text);
        return material;
    }
    
    //解析场景JSON
    function parse(text){
        var loader = new THREE.ObjectLoader();
        var object = loader.parse(text);
        return object;
    }
    
    //解析JSON格式的模型
    function JSONparse(text) {
        var loader = new THREE.JSONLoader();
        var object = loader.parse(text);
        return object;
    }
    
    return new objLoder();
});